<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/base}">
<head>
    <title>控制台 - 快递管理系统</title>
</head>
<body>
    <div layout:fragment="content">
        <h2 class="mb-4">控制台</h2>
        
        <!-- 统计卡片 -->
        <div class="row">
            <div class="col-md-3 mb-4">
                <div class="card bg-primary text-white">
                    <div class="card-body">
                        <h5 class="card-title">今日订单</h5>
                        <p class="card-text display-4" th:text="${todayOrders}">0</p>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card bg-success text-white">
                    <div class="card-body">
                        <h5 class="card-title">待处理包裹</h5>
                        <p class="card-text display-4" th:text="${pendingPackages}">0</p>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card bg-info text-white">
                    <div class="card-body">
                        <h5 class="card-title">在途包裹</h5>
                        <p class="card-text display-4" th:text="${inTransitPackages}">0</p>
                    </div>
                </div>
            </div>
            <div class="col-md-3 mb-4">
                <div class="card bg-warning text-white">
                    <div class="card-body">
                        <h5 class="card-title">已送达包裹</h5>
                        <p class="card-text display-4" th:text="${deliveredPackages}">0</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- 最近订单 -->
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0">最近订单</h5>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>订单号</th>
                                <th>发件人</th>
                                <th>收件人</th>
                                <th>状态</th>
                                <th>创建时间</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr th:each="order : ${recentOrders}">
                                <td th:text="${order.orderNumber}"></td>
                                <td th:text="${order.senderName}"></td>
                                <td th:text="${order.receiverName}"></td>
                                <td>
                                    <span class="badge" th:classappend="${order.status == 'PENDING' ? 'bg-warning' :
                                                                      (order.status == 'SHIPPED' ? 'bg-primary' :
                                                                      (order.status == 'PICKED_UP' ? 'bg-info' :
                                                                      (order.status == 'IN_TRANSIT' ? 'bg-info' :
                                                                      (order.status == 'UNRECEIVED' ? 'bg-danger' :
                                                                      (order.status == 'DELIVERED' ? 'bg-success' :
                                                                      (order.status == 'CANCELED' ? 'bg-secondary' : 'bg-secondary'))))))}"
                                          th:text="${displayStatusMap.get(order.status)}">
                                    </span>
                                </td>
                                <td th:text="${#temporals.format(order.createdAt, 'yyyy-MM-dd HH:mm')}"></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
</html> 